<?php

class Zend_Controller_Action_Helper_Authorization extends Zend_Controller_Action_Helper_Abstract
{
    public function direct($login, $password)
    {
        $authAdapter = new Zend_Auth_Adapter_Digest(APPLICATION_PATH . '/configs/auth', 'administrator', $login, $password);
        $result = $authAdapter->authenticate();

        if ($result->isValid()) {
            Zend_Auth::getInstance()->getStorage()->write($authAdapter->getRealm());
        }

        return $result;
    }

    public function logout()
    {
        Zend_Auth::getInstance()->clearIdentity();
        Zend_Session::forgetMe();
        return true;
    }

}